package ecnu.liwaTest.dd.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;

import java.util.Map;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Map;

import static ecnu.liwaTest.dd.DriverSingleton.*;

public class LoginPage extends BasePage{

    WebDriver driver = getChromeDriver();
    JavascriptExecutor js = getJs();
    Map<String, Object> vars = getVars();

    public LoginPage goLoginPage() {
        driver.get("https://sei-test.021hqit.com/group-2/#/login");
        driver.manage().window().setSize(new Dimension(1296, 736));
        waitForWindow(2000);
        assertThat(driver.getTitle(), is("登录"));
        return this;
    }

    public LoginPage typeLoginInform(String username, String password) {
        driver.findElement(By.cssSelector(".el-form-item:nth-child(1) .el-input__inner")).click();
        driver.findElement(By.cssSelector(".el-form-item:nth-child(1) .el-input__inner")).sendKeys(username);
        driver.findElement(By.cssSelector(".el-form-item:nth-child(2) .el-input__inner")).click();
        driver.findElement(By.cssSelector(".el-form-item:nth-child(2) .el-input__inner")).sendKeys(password);
        return this;
    }

    public LoginPage clickLogin() {
        driver.findElement(By.cssSelector(".el-button")).click();
        return this;
    }

}
